'''
Created on 2010-1-10

@author: jazy
'''

import ctypes
import pcap_c_types

class If(object):
    '''
    interface
    '''
    def __init__(self,pif):
        '''
        Constructor
        '''
        self.pif=pif
        self.name=pif[0].name
        self.description=pif[0].description
        self.addresses=pif[0].addresses
        self.flags=pif[0].flags
        
    def __iter__(self):
        return self

    
    def next(self):
        '''
        '''
        #a terrible hack,but i don't know how to assert null pointer in ctypes
        try:
            tmp_if=If(self.pif)
            self.pif=self.pif[0].next
            return tmp_if
        except ValueError:
            raise StopIteration

            
    
